<?php

namespace core;
class pllx{

    public static $casllMap = [];

    /**
     * 加载 控制器
     * @throws \Exception
     */
    static public function run(){
        $route = new \core\lib\route();
        $ctrlClass  = $route->ctrl;
        $action = $route->action;
        $ctrlfile = APP.'/ctrl/'.$ctrlClass.'Ctrl.php';
        $ctrlClass = '\\'.MODUEl.'\\ctrl\\'.$ctrlClass.'Ctrl';
        if (is_file($ctrlfile)){
            include $ctrlfile;
            $ctrl = new $ctrlClass();
            $ctrl->$action();
        }else{
            throw new \Exception('找不到控制器'.$ctrlClass);
        }


    }

    /**
     * 自动加载
     * @param $class
     * @return bool
     */
    static public function load($class){
        if (isset($classMap[$class])){
            return true;
        }else{
            $class = str_replace('\\','/',$class);
            $file =PLLX.'/'.$class.'.php';
            if (is_file($file)){
                include $file;
                self::$casllMap[$class] = $class;
            }else{
                return false;
            }
        }
    }
}